<?php

// $Id$

require_once(TANGRA_MAIN_DIR.'db/paginate_db_data.class.php');
require_once(TANGRA_MAIN_DIR.'grids/grid_ctrl.class.php');

require_once($WSC->get_site_inc_dir().'modules/tangra_cms/grids/nomenclature_values/nomenclature_values_grid.class.php');
require_once($WSC->get_site_inc_dir().'modules/tangra_cms/classes/nomenclature/tcms_nomenclature_value_dbc.class.php');


class Nomenclature_Values_Grid_Ctrl extends Grid_Ctrl {
	private $nomenclature_id;

	function __construct($system_name, Vars_Manager $vm, $method = Tangra_Parameter_Method::GET, $nomenclature_id) {
		tangra_if_not_int_throw_e($nomenclature_id);
		$this->nomenclature_id = $nomenclature_id;

		parent::__construct($system_name, $vm, $method);
	}


	protected function create_grid() {
		$ret = new Nomenclature_values_Grid();

		return $ret;
	}


	protected function create_paginate_db_data() {
		$sqls = TCMS_Nomenclature_Value_DBC::get_sql_for_grid($this->nomenclature_id);
		$sqlc = TCMS_Nomenclature_Value_DBC::get_sql_count_for_grid($this->nomenclature_id);

		$pdbd = new Paginate_DB_Data($this->grid->get_page_size(), $sqls, $sqlc);

		return $pdbd;
	}
}